import { post, get } from "../../../utils/request";
import utils from "../../../utils/utils";
const env = import.meta.env;

const apiPublication = {
  savePublication(data: object) {
    return post(
      env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/publication.save",
      data
    );
  },
  deletePublication(publicationId: string) {
    return post(
      env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/publication.delete",
      {
        publicationId: publicationId,
      }
    );
  },
  getPublication(publicationId: string) {
    return get(env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/publication.get", {
      publicationId: publicationId,
    });
  },
  queryPublicationListing(data?: object) {
    return post(
      env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/publication.listing",
      data
    );
  },
  generateSitemap(siteName: string) {
    return get(env.VITE_API_CMS_CONTEXT_PATH + "/admin/v1/sitemap.get", {
      siteName,
    });
  },
  downloadSitemap(siteName: string) {
    return (
      env.VITE_API_CMS_CONTEXT_PATH +
      "/admin/v1/sitemap.get?siteName=" +
      siteName +
      "&x-summer-token=" +
      window.store.tokenInfo.token
    );
  },
};

export default apiPublication;
